<?php
/**
 * 办事流程静态文件
 *
 */
apf_require_class('Const_User');
class Const_Flow {
    /**
     * 待办事项进行中
     */
    const FLOW_STATUS_DOING = 1;
    /**
     * 已生效
     */
    const FLOW_STATUS_EFFECT = 2;
    /**
     * 已取消
     */
    const FLOW_STATUS_CANCEL = 3;
    const FLOW_STATUS_SYSTEM = 4;
    /**
     * 处理超时-自动撤销
     */
    const FLOW_STATUS_CANCEL_SYSTEM = 4;
    /**
     *入职
     * @var unknown_type
     */
    const FLOW_TYPE_ENTRY     = 1;
    /**
     * 转岗
     * @var unknown_type
     */
    const FLOW_TYPE_TRANSFER  = 2;
    /**
     * 离职
     * @var unknown_type
     */
    const FLOW_TYPE_DIMISSION = 3;
    /**
     * 调薪调职级
     */
    const FLOW_TYPE_MONEY     = 4;

    const FLOW_TYPE_REGULAR     = 6;//转正
    const FLOW_TYPE_RENEW       = 7;//续签
    /**
     * 招聘申请
     */
    const FLOW_TYPE_RECRUIT   = 5;
    /**
     * 确认入职
     */
    const ENTRY_OK = 1;
    /**
     * 取消入职
     */
    const ENTRY_CANCEL = 2;
    /**
     * 入职流程 3大阶段
     * @var unknown_type
     */
    const FLOW_ENTRY_1 = 1;
    const FLOW_ENTRY_2 = 2;
    const FLOW_ENTRY_3 = 3;
    const FLOW_ENTRY_4 = 4;
    /**
     * 异动流程 7大阶段
     * @var unknown_type
     */
    const FLOW_TRANSFER_1 = 1;
    const FLOW_TRANSFER_2 = 2;
    const FLOW_TRANSFER_3 = 3;
    const FLOW_TRANSFER_4 = 4;
    const FLOW_TRANSFER_5 = 5;
    const FLOW_TRANSFER_6 = 6;
    const FLOW_TRANSFER_7 = 7;
    /**
     * 薪资调整 6大阶段
     * @var unknown_type
     */
    const FLOW_MONEY_1 = 1;
    const FLOW_MONEY_2 = 2;
    const FLOW_MONEY_3 = 3;
    const FLOW_MONEY_4 = 4;
    const FLOW_MONEY_5 = 5;
    const FLOW_MONEY_6 = 6;
    /**
     * 离职流程 6大阶段
     * @var unknown_type
     */
    const FLOW_DIMISSION_1 = 1;
    const FLOW_DIMISSION_2 = 2;
    const FLOW_DIMISSION_3 = 3;
    const FLOW_DIMISSION_4 = 4;
    const FLOW_DIMISSION_5 = 5;
    const FLOW_DIMISSION_6 = 6;

    /**
     * 招聘申请 6大阶段
     */
    const FLOW_RECRUIT_1 = 1;
    const FLOW_RECRUIT_2 = 2;
    const FLOW_RECRUIT_3 = 3;
    const FLOW_RECRUIT_4 = 4;
    const FLOW_RECRUIT_5 = 5;
    const FLOW_RECRUIT_6 = 6;
    const FLOW_RECRUIT_7 = 7;
    const FLOW_RECRUIT_8 = 8;
    const FLOW_RECRUIT_9 = 9;
    const FLOW_RECRUIT_10 = 10;
    const FLOW_RECRUIT_11 = 11;
    const FLOW_RECRUIT_12 = 12;
    const FLOW_RECRUIT_13 = 13;
    const FLOW_RECRUIT_14 = 14;

    const FLOW_REGULAR_1 = 1;
    const FLOW_REGULAR_2 = 2;

    const FLOW_RENEW_1 = 1;
    const FLOW_RENEW_2 = 2;

    /**
     * 普通员工
     * @var unknown_type
     */
    const ROLE_STAFF   = 1;  //普通员工
    /**
     * 行政招聘
     * @var unknown_type
     */
    const ROLE_RECRUIT = 2;  //行政招聘
    /**
     * 行政管理
     * @var unknown_type
     */
    const ROLE_ADMIN   = 3;  //行政管理
    /**
     *IT管理
     * @var unknown_type
     */
    const ROLE_IT      = 4;  //IT管理
    /**
     * HR绩效
     * @var unknown_type
     */
    const ROLE_HR      = 5;  //HR绩效
    /**
     * HRD
     * @var unknown_type
     */
    const ROLE_HRD     = 6;  //HRD
    /**
     * 财务管理
     * @var unknown_type
     */
    const ROLE_FIN     = 7;  //财务管理
    /**
     * 图书管理员
     * @var unknown_type
     */
    const ROLE_BOOK    = 8;  //图书管理员
    /**
     * 主管
     * @var unknown_type
     */
    const ROLE_SUPERIOR    = 9;  //主管P4、M7以上的人
    /**
     * CEO
     * @var unknown_type
     */
    const ROLE_CEO = 10;

    const ROLE_SYSTEM = 100;//系统使用特殊角色

    const PHASE_1 = 1;
    const PHASE_2 = 2;
    const PHASE_3 = 3;
    const PHASE_4 = 4;
    const PHASE_5 = 5;
    const PHASE_6 = 6;
    const PHASE_7 = 7;
    const PHASE_8 = 8;

    const PHASE_11 = 11;
    const PHASE_12 = 12;
    const PHASE_13 = 13;
    const PHASE_14 = 14;
    const PHASE_15 = 15;
    const PHASE_16 = 16;
    const PHASE_17 = 17;
    const PHASE_18 = 18;

    const PHASE_28 = 28;
    const PHASE_29 = 29;
    const PHASE_30 = 30;
    const PHASE_31 = 31;
    const PHASE_32 = 32;
    const PHASE_33 = 33;
    const PHASE_34 = 34;
    const PHASE_35 = 35;
    const PHASE_36 = 36;
    const PHASE_37 = 37;

    const PHASE_50 = 50;
    const PHASE_51 = 51;
    const PHASE_52 = 52;
    const PHASE_53 = 53;
    const PHASE_54 = 54;
    const PHASE_55 = 55;
    const PHASE_56 = 56;
    const PHASE_70 = 70;
    const PHASE_71 = 71;
    const PHASE_72 = 72;
    const PHASE_73 = 73;
    const PHASE_74 = 74;
    const PHASE_75 = 75;
    const PHASE_76 = 76;

    const PHASE_40 = 40;
    const PHASE_41 = 41;

    const PHASE_60 = 60;
    const PHASE_61 = 61;


    public static function flow_type(){
        return array(
                 self::FLOW_TYPE_ENTRY=>'入职',
                 self::FLOW_TYPE_TRANSFER=>'转岗',
                 self::FLOW_TYPE_DIMISSION=>'离职',
                 self::FLOW_TYPE_MONEY => '调薪/职级',
                 self::FLOW_TYPE_RECRUIT=>'招聘',
                 self::FLOW_TYPE_REGULAR=>'续签',
                 self::FLOW_TYPE_RENEW=>'转正',
        );
    }
    /**
     * 操作列表
     */
    public static function phase_list(){
        return array(
                1=>'入职-新建员工档案',
                2=>'入职-行政管理',
                3=>'入职-IT管理',
                4=>'入职-HR确认',
                5=>'入职-HR取消',
                6=>'入职-取消新建员工档案',
                7=>'入职-IT确认关闭权限',
                8=>'入职-行政确认收回',

                11=>'异动-主管申请',
                12=>'异动-原主管确认',
                13=>'异动-申请人主管审批',
                14=>'异动-HR审批',
                15=>'异动-HRD审批',
                16=>'异动-行政管理',
                17=>'异动-IT管理',
                18=>'异动-HR确认',

                28=>'离职-辞退员工',
                29=>'离职-申请离职',
                30=>'离职-主管审批',
                31=>'离职-交接资料',
                32=>'离职-主管确认',
                33=>'离职-财务管理',
                34=>'离职-技术图书管理员',
                35=>'离职-IT管理',
                36=>'离职-行政管理',
                37=>'离职-HR确认',

                50=>'招聘-发起招聘',
                51=>'招聘-一级主管审批',
                52=>'招聘-二级主管审批',
                53=>'招聘-三级主管审批',
                54=>'招聘-招聘审批',
                55=>'招聘-HRD审批',
                56=>'招聘-CEO审批',

                70=>'招聘-4级主管审批',
                71=>'招聘-5级主管审批',
                72=>'招聘-6级主管审批',
                73=>'招聘-7级主管审批',
                74=>'招聘-8级主管审批',
                75=>'招聘-9级主管审批',
                76=>'招聘-10级主管审批',

                40=>'转正-发起流程',
                41=>'转正-主管审批',

                60=>'续签-发起流程',
                61=>'续签-主管审批',
                );
    }
    /**
     * 流程 阶段对应角色 角色对应操作列表 判断流程进入哪个阶段使用
     */
    public static function flow_to_opt(){
        return array(
                self::FLOW_TYPE_ENTRY     => array(//入职流程
                        self::FLOW_ENTRY_1 => array(
                                self::ROLE_RECRUIT => self::PHASE_1,
                        ),
                        self::FLOW_ENTRY_2 => array(
                                self::ROLE_ADMIN => self::PHASE_2,
                                self::ROLE_IT   => self::PHASE_3
                        ),
                        self::FLOW_ENTRY_3 => array(
                                self::ROLE_HR => self::PHASE_4,
                        ),
                        self::FLOW_ENTRY_4 => array(
                                self::ROLE_ADMIN => self::PHASE_8,
                                self::ROLE_IT   => self::PHASE_7
                        ),
                ),
                self::FLOW_TYPE_TRANSFER  => array(//异动流程
                        self::FLOW_TRANSFER_1 => array(
                                self::ROLE_SUPERIOR => self::PHASE_11
                        ),
                        self::FLOW_TRANSFER_2 => array(
                                self::ROLE_SUPERIOR => self::PHASE_12
                            ),
                        self::FLOW_TRANSFER_3 => array(
                                self::ROLE_SUPERIOR => self::PHASE_13
                            ),
                        self::FLOW_TRANSFER_4 => array(
                                self::ROLE_HR => self::PHASE_14
                            ),
                        self::FLOW_TRANSFER_5 => array(
                                self::ROLE_HRD => self::PHASE_15
                            ),
                        self::FLOW_TRANSFER_6 => array(
                                self::ROLE_ADMIN => self::PHASE_16,
                                self::ROLE_IT => self::PHASE_17
                            ),
                        self::FLOW_TRANSFER_7 => array(
                                self::ROLE_HR => self::PHASE_18
                            ),
                ),
                self::FLOW_TYPE_DIMISSION => array(//离职流程
                        self::FLOW_DIMISSION_1 => array(
                                self::ROLE_STAFF => self::PHASE_29,
                                self::ROLE_HR    => self::PHASE_28
                        ),
                        self::FLOW_DIMISSION_2 => array(
                                self::ROLE_SUPERIOR => self::PHASE_30
                        ),
                        self::FLOW_DIMISSION_3 => array(
                                self::ROLE_STAFF => self::PHASE_31
                        ),
                        self::FLOW_DIMISSION_4 => array(
                                self::ROLE_SUPERIOR => self::PHASE_32
                        ),
                        self::FLOW_DIMISSION_5 => array(
                                self::ROLE_FIN      => self::PHASE_33,
                                self::ROLE_BOOK     => self::PHASE_34,
                                self::ROLE_IT       => self::PHASE_35,
                                self::ROLE_ADMIN    => self::PHASE_36
                        ),
                        self::FLOW_DIMISSION_6 => array(
                                self::ROLE_HR => self::PHASE_37
                        ),
                ),
                self::FLOW_TYPE_MONEY => array(//调薪/调职级流程
                        self::FLOW_MONEY_1 => array(
                                self::ROLE_SUPERIOR => self::PHASE_11
                        ),
                        self::FLOW_MONEY_2 => array(
                                self::ROLE_SUPERIOR => self::PHASE_12
                        ),
                        self::FLOW_MONEY_3 => array(
                                self::ROLE_SUPERIOR => self::PHASE_13
                        ),
                        self::FLOW_MONEY_4 => array(
                                self::ROLE_HR => self::PHASE_14
                        ),
                        self::FLOW_MONEY_5 => array(
                                self::ROLE_HRD => self::PHASE_15
                        ),
                        self::FLOW_MONEY_6 => array(
                                self::ROLE_HR => self::PHASE_18
                        ),
                ),

                self::FLOW_TYPE_RECRUIT => array(//招聘
                        self::FLOW_RECRUIT_1 => array(
                                self::ROLE_STAFF => self::PHASE_50
                        ),
                        self::FLOW_RECRUIT_2 => array(
                                self::ROLE_SUPERIOR => self::PHASE_51
                        ),
                        self::FLOW_RECRUIT_3 => array(
                                self::ROLE_SUPERIOR => self::PHASE_52
                        ),
                        self::FLOW_RECRUIT_4 => array(
                                self::ROLE_SUPERIOR => self::PHASE_53
                        ),
                         self::FLOW_RECRUIT_5 => array(//四级主管
                                self::ROLE_SUPERIOR => self::PHASE_70
                        ),
                        self::FLOW_RECRUIT_6 => array(//五级主管
                                self::ROLE_SUPERIOR => self::PHASE_71
                        ),
                        self::FLOW_RECRUIT_7 => array(//6级主管
                                self::ROLE_SUPERIOR => self::PHASE_72
                        ),
                        self::FLOW_RECRUIT_8 => array(//7级主管
                                self::ROLE_SUPERIOR => self::PHASE_73
                        ),
                        self::FLOW_RECRUIT_9 => array(//8级主管
                                self::ROLE_SUPERIOR => self::PHASE_74
                        ),
                        self::FLOW_RECRUIT_10 => array(//9级主管
                                self::ROLE_SUPERIOR => self::PHASE_75
                        ),
                        self::FLOW_RECRUIT_11 => array(//10级主管
                                self::ROLE_SUPERIOR => self::PHASE_76
                        ),
                        self::FLOW_RECRUIT_12 => array(
                                self::ROLE_HRD => self::PHASE_55
                        ),
                        self::FLOW_RECRUIT_13 => array(
                                self::ROLE_CEO => self::PHASE_56
                        ),
                        self::FLOW_RECRUIT_14 => array(//分公司招聘
                                self::ROLE_RECRUIT => self::PHASE_54
                        ),
                ),
                self::FLOW_TYPE_REGULAR => array(//转正
                        self::FLOW_REGULAR_1 => array(
                                self::ROLE_SYSTEM => self::PHASE_40
                        ),
                        self::FLOW_REGULAR_2 => array(
                                self::ROLE_SUPERIOR => self::PHASE_41
                        ),
                ),
                self::FLOW_TYPE_RENEW => array(//续签
                        self::FLOW_RENEW_1 => array(
                                self::ROLE_SYSTEM => self::PHASE_60
                        ),
                        self::FLOW_RENEW_2 => array(
                                self::ROLE_SUPERIOR => self::PHASE_61
                        ),
                ),
        );
    }
    /**
     * 根据当前阶段获取可编辑的阶段
     */
    public static function get_edit_stage($flow_type,$flow_stage){
        $opt = self::flow_to_opt();
        $stage_list = $opt[$flow_type];
        $stage =array($flow_stage);
        if($flow_stage==1){
            return $stage;
        }
        return $flow_stage-1;
    }
    //角色
    public static function role_list(){
        return array(
            self::ROLE_STAFF=>'普通员工',
            self::ROLE_RECRUIT=>'招聘',
            self::ROLE_ADMIN=>'行政',
            self::ROLE_IT=>'IT',
            self::ROLE_HR=>'HR',
            self::ROLE_HRD=>'HRD',
            self::ROLE_FIN=>'财务',
            self::ROLE_BOOK=>'图书',
            self::ROLE_SUPERIOR=>'主管',
            self::ROLE_CEO=>'CEO',
            self::ROLE_SYSTEM=>'系统处理',
        );
    }
    //办公地点
    public static function office_address(){
        return array(
                11=>array(
                        'SH01'=>'上海市浦东新区陆家嘴环路166号未来资产大厦10、11楼',
                        'SH02'=>'上海市浦东新区杨高南路428号由由世纪广场3号楼7楼',
                ),
                14=>array('北京市朝阳区东三环北路甲19号SOHO嘉盛中心20楼'),
                33=>array('安徽省合肥市包河区马鞍山路130号万达广场6楼2208-2210室'),
                15=>array('四川省成都市航天科技大厦新光华街7号17楼01-03室'),
                20=>array('重庆市渝中区新华路388号创汇首座0608室'),
                34=>array('广东省东莞市南城区鸿福路92号中环财富广场913A'),
                24=>array('广东省佛山市禅城区季华五路21号金海广场1309-1310室'),
                12=>array('广东省广州市越秀区中山三路33号中华国际中心B座5607-5609室'),
                52=>array('广东省惠州市江北文明一路3号中信城市时代2单元17层03室'),
                13=>array('广东省深圳市福田区金田路3037号金中环商务大厦4503-4505室'),

                35=>array('福建省福州市鼓楼区东水路88号闽发大厦商住楼四区写字楼20层03单元'),
                46=>array('福建省厦门市思明区鹭江道96号之一2105室'),
                26=>array('河南省郑州市金水区花园路39号国贸中心招银大厦1602、2103室'),
                28=>array('河北省石家庄市长安区中山东路265号汇景国际4-1107室'),
                51=>array('海南省三亚市三亚湾路166号蓝海三期G栋1801室'),
                27=>array('湖南省长沙市雨花区劳动西路528号大华宾馆写字楼26楼10-14室'),
                22=>array('湖北省武汉市硚口区解放大道686号世界贸易大厦1118室'),

                17=>array('天津市和平区南京路85号君隆广场B1-503、504室'),
                50=>array('吉林省长春市朝阳区西安大路727号中银大厦A座401室'),
                21=>array('辽宁省大连市中山区人民路23号虹源大厦2810室','大连市沙口区成义街10号25层15号、17号、29号'),
                39=>array('辽宁省沈阳市和平区中华路69-1号富丽华国际商务中心1001-1002室'),

                40=>array('江苏省昆山市开发区庐南路999号吉田国际广场2号楼504室'),
                41=>array('江西省南昌市西湖区广场南路205号恒茂国际中心16栋A单元907室'),
                16=>array('江苏省南京市白下区中山南路1号南京中心35层A4-B'),
                25=>array('江苏省无锡市北塘区兴源北路600号902室'),
                19=>array('江苏省苏州市平江区干将东路666号和基广场513、517室'),
                31=>array('陕西省西安市碑林区和平路116号金鼎大厦309-310室'),

                38=>array('山西省太原市小店区南内环街98-2号财富国际大厦1312室'),
                23=>array('山东省济南市市中区经四路9号万达广场A座1807室'),
                30=>array('山东省青岛市市南区东海西路15号英德隆大厦6D'),
                36=>array('云南省昆明市五华区青年路387号华一广场13楼E座'),
                18=>array('浙江省杭州市下城区庆春路118号广利大厦1205-1207室','浙江省杭州市临安区锦城街道尚城国际大厦1幢915室'),
                32=>array('浙江省宁波市海曙区和义路77号汇金大厦1405室'),
                );
    }
    /**
     * 入职电脑类别
     * @return multitype:string
     */
    public static function computer_type(){
        return array(
            1=>'台式（技术）',
            2=>'台式（文员）',
            3=>'笔记本（技术）',
            4=>'笔记本（文员）',
            5=>'不配电脑'
        );
    }
    /**
     *资薪异动原因
     */
    public static function salary_type($type=0){
         $return = array(
                1=>'试用期滿',
                2=>'年资调整',
                3=>'学历调整',
                4=>'绩效考核调整',
                5=>'岗位异动',
                6=>'其它'
         );
         if($type){
             $return = $return[$type];
         }
         return $return;
    }
    /**
     * 异动类型
     * @return multitype:string
     */
    public static function transfer_type($type=0){
        $return = array(
                1=>'晋升',
                2=>'调任',
                3=>'降职',
                4=>'派驻',
                5=>'其它'
        );
        if($type){
            $return = $return[$type];
        }
        return $return;
    }
    /**
     * 离职 财务结算
     * @return multitype:string
     */
    public static function finan_list(){
        return array(
            1=>'财务报销',
            2=>'工资代扣'
        );
    }
    /**
     * 离职 行政回收
     * @return multitype:string
     */
    public static function office_supply(){
        return array(
            1=>'员工证',
            2=>'门禁卡',
            3=>'办公用具',
            4=>'名片',
            5=>'钥匙',
            6=>'电脑',
            7=>'办公电话/电话端口',
        );
    }
    /**
     * 离职确认
     */
    public static function hr_confirm(){
        return array(
                1=>'退工单/离职证明',
                2=>'退保险',
                3=>'退公积金',
                4=>'修改员工资讯',
        );
    }
    /**
     * 核心能力
     */
    public static function work_core(){
        return array(
                1=>'沟通能力',
                2=>'分析能力',
                3=>'谈判能力',
                4=>'领导能力',
                5=>'统筹能力',
                6=>'质量导向',
                7=>'团队合作',
                8=>'结果导向',
                9=>'关注细节',
                10=>'个人驱动力',
                11=>'抗压性',
                12=>'责任感',
                13=>'坚韧性',
                14=>'执行力',
                15=>'解决问题力',
                );
    }
    /**
     * p1=>s1
     * p4=>m1
     * p13=>m10
     * @param unknown_type $type
     * @return Ambigous <multitype:, multitype:string Ambigous <number, string> >
     */
    public static function turn_p_m($type='p'){
        if($type=='p'){
            $list = Const_User::get_p_degree();
        }else{
            $list = Const_User::get_m_degree();
        }
        $res = array();
        if($type=='m'){
            $res=array(
                    1=>'S1',
                    2=>'S2',
                    3=>'S3',
            );
            $i=4;
        }else{
            $i=1;
        }
        foreach($list as $k=>$val){
            if($k==99){
                continue;
            }
            $res[$i]=$val['degree'];
            $i++;
        }
        return $res;
    }
    /**
     * p=>m
     * @param unknown_type $level
     * @return multitype:|multitype:unknown
     */
    public static function p_turn_m($level){
        $res = array();
        if($level < 4){
            return $res;
        }
        $list = self::turn_p_m('m');
        foreach($list as $key=>$val){
            if($key < 4){
                continue;
            }
            if( $key<= $level){
                $key-=3;
                $res[$key]=$val;
            }
        }
        return $res;
    }
    /**
     * m=>p
     * @param unknown_type $level
     * @return multitype:|multitype:unknown
     */
    public static function m_turn_p($level){
        $res = array();
        if(!$level){
            return $res;
        }
        $list = self::turn_p_m();
        $level +=3;
        foreach($list as $key=>$val){
            if($key <= $level){
                $res[$key]=$val;
            }
        }
        return $res;
    }
}